home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / WebObjects / WebObjectsDoc_HTML / Reuse / ReusableComponentsEx / FileEditor.wo / FileEditor.wos < prev    next >
Encoding:
Text File  |  1996-03-02  |  1.1 KB  |  66 lines

  1. ////////////////////////
  2. //  FileEditor
  3. //  by Charles Lloyd
  4. ////////////////////////
  5.  
  6.  
  7. /////////////////////////
  8. //  User Settable
  9. /////////////////////////
  10. id pathName;
  11. id rows;
  12. id cols;
  13.  
  14. /////////////////////////
  15. //  Internal State
  16. /////////////////////////
  17. persistent id fileContentsString;
  18. persistent id fileNotWritten;
  19. id borderSize;
  20.  
  21. - awake
  22. {
  23.     borderSize = 2;
  24.     rows = 15;
  25.     cols = 65;
  26.     if (!fileContentsString) {
  27.         fileNotWritten = nil;
  28.     }
  29. }
  30.  
  31. - setPathName:aPath
  32. {
  33.     pathName = aPath;
  34.     if (!fileContentsString) {
  35.         fileContentsString = [NSString stringWithContentsOfFile:pathName];
  36.     }
  37. }
  38.  
  39. - abbreviatedPathName
  40. {
  41.     return [pathName lastPathComponent];
  42. }
  43.  
  44. - setAbbreviatedPathName:aString
  45. {
  46.     return nil;
  47. }
  48.  
  49. - saveFile
  50. {
  51.     id aBool;
  52.     id aDataObject = [fileContentsString
  53.                 dataUsingEncoding:1];
  54.     aBool = [aDataObject writeToFile:pathName atomically:YES];
  55.     if (aBool == NO) {
  56.         fileNotWritten = YES;
  57.     } else {
  58.         fileNotWritten = NO;
  59.     }
  60. }
  61.  
  62. - revertFile
  63. {
  64.     fileContentsString = [NSString stringWithContentsOfFile:pathName];
  65. }
  66.